﻿using RMS.Common;
using RMS.Manage.Web.Controllers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace RMS.Manage.Web.Areas.Demo.Controllers
{
    public class UIElementsController : BaseController
    {
        /// <summary>
        /// 面板
        /// </summary>
        /// <returns></returns>
        public ActionResult Panels()
        {
            return View();
        }
        /// <summary>
        /// 按钮
        /// </summary>
        /// <returns></returns>
        public ActionResult Buttons()
        {
            return View();
        }
        /// <summary>
        /// 通知
        /// </summary>
        /// <returns></returns>
        public ActionResult Notifications()
        {
            return View();
        }
        /// <summary>
        /// 排版
        /// </summary>
        /// <returns></returns>
        public ActionResult Typography()
        {
            return View();
        }
        /// <summary>
        /// 图标
        /// </summary>
        /// <returns></returns>
        public ActionResult Icons()
        {
            return View();
        }
        /// <summary>
        /// 布局
        /// </summary>
        /// <returns></returns>
        public ActionResult Grid()
        {
            return View();
        }
        /// <summary>
        /// 编辑器
        /// </summary>
        /// <returns></returns>
        [ValidateInput(false)]//文本编辑器会提示Html注入错误，需配合修改
        public ActionResult Editor()
        {
            var CKEditorText = Request.Form["CKEditorText"];
            var Modal_CKEditorText = Request.Form["Modal_CKEditorText"];
            return View();
        }

        /// <summary>
        /// 上传
        /// </summary>
        /// <returns></returns>
        public ActionResult Upload()
        {
            return View();
        }
        /// <summary>
        /// 图片上传方法
        /// </summary>
        /// <returns></returns>
        //[HttpPost]
        [AllowAnonymous]
        public ActionResult UploadImage()
        {
            var IsSuccess = false;
            var Message = string.Empty;
            var FileUpladAudio = "/Upload/Demo/Upload/";
            var file = Request.Files["Filedata"];
            IsSuccess = FileHelper.SaveAutoName(file, FileUpladAudio, out Message);
            if (IsSuccess == false)
            {
                if (Message == "NoFile")
                {
                    Message = "请上传图片";
                }
            }
            var fullPath = Server.MapPath(Message);//全路径
            var fileName = System.IO.Path.GetFileName(Message);//文件名
            var cutName = System.IO.Path.GetFileNameWithoutExtension(Message) + "cut.jpg";//截取文件名
            var cutPath = System.IO.Path.GetDirectoryName(fullPath) + "\\" + cutName;//截取全路径
            FileHelper.GetCutThumImage(fullPath, cutPath, 300, 300);

            Message = cutPath.Substring(Server.MapPath("/").Length - 1);
            return Json(new { IsSuccess = IsSuccess, Message = Message }, "text/json", JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 时间选择器
        /// </summary>
        /// <returns></returns>
        public ActionResult DatetimePicker()
        {
            return View();
        }
        /// <summary>
        /// 树状图
        /// </summary>
        /// <returns></returns>
        public ActionResult TreeView()
        {
            return View();
        }
        /// <summary>
        /// 下拉
        /// </summary>
        /// <returns></returns>
        public ActionResult Dropdown()
        {
            return View();
        }
	}
}